package com.myk.game.gobangchess.utils;

import java.util.Timer;

public class CountDownTimer extends Timer {
    private final long startTime;
    private final int countDownSec;

    public CountDownTimer( int countDownSec) {
        this.startTime = System.currentTimeMillis();
        this.countDownSec = countDownSec;
    }

    /**
     * 剩余秒数
     */
    public int getRemainingSec() {
        int passedSec = (int) ((System.currentTimeMillis() - startTime) / 1000F);
        if (countDownSec > passedSec) {
            return countDownSec - passedSec;
        }
        else {
            return 0;
        }
    }
}
